#pragma once

#include "Comment.h"

#include "Element.h"

namespace uml {

const QString Comment::body_default_ = "";
void Comment::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    JsonSerializable::fromJsonArray(annotatedElements_, "annotatedElements", json, errorList);
    body_ = json.value("body").toString(body_default_);
}

void Comment::toJson(QJsonObject& json) {
    JsonSerializable::toJsonArray(annotatedElements_, "annotatedElements", json);
    if (body_ != body_default_) {
        json.insert("body", body_);
    }
}

/// <summary>
/// annotatedElements getter
/// References the Element(s) being commented.
/// </summary>
vector<shared_ptr<Element>>& Comment::annotatedElements() {
    return annotatedElements_;
}

/// <summary>
/// body getter
/// Specifies a string that is the comment.
/// </summary>
QString Comment::body() const {
    return body_;
}

/// <summary>
/// body setter
/// Specifies a string that is the comment.
/// </summary>
void Comment::setBody(const QString& value) {
    body_ = value;
}

} // namespace uml
